/*
 * @(#)TemplateDirectiveType.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.result.template.directive;

import java.util.Map;

import freemarker.template.TemplateDirectiveModel;

/**
 * @author Web Platform Development Team
 */
public enum TemplateDirectiveType {
    SCRIPT, SETCOOKIE, GETCOOKIE, PAGE, RESOURCE;

    /**
     * Gets the type.
     *
     * @param type the type
     * @return the type
     */
    public static String getType(TemplateDirectiveType type) {
        switch (type) {
            case SCRIPT:
                return "script";
            case SETCOOKIE:
                return "setcookie";
            case GETCOOKIE:
                return "getcookie";
            case PAGE:
                return "paging";
            case RESOURCE:
                return "resource";
            default:
                return "";
        }
    }

    /**
     * Gets the uSF template directive.
     *
     * @param type      the type
     * @param inputData the input data
     * @return the uSF template directive
     */
    @SuppressWarnings("unchecked")
	public static TemplateDirectiveModel getUSFTemplateDirective(TemplateDirectiveType type, Map inputData) {
        switch (type) {
            case SCRIPT:
                return new ScriptDirective(inputData);
            case SETCOOKIE:
                return new SetCookieDirective(inputData);
            case GETCOOKIE:
                return new GetCookieDirective(inputData);
            case PAGE:
                return new PageNavigatorDirective();
            case RESOURCE:
                return new ResourceDirective();
            default:
                return null;
        }
    }
}